@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@300..700&display=swap');

body {
  font-family: 'Fredoka', sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  padding-top: 60px;
  background: linear-gradient(135deg, #ffccdd 0%, #ffeaa7 25%, #cceeff 50%, #dda0dd 75%, #ffccdd 100%);
  background-size: 400% 400%;
  animation: gradientShift 8s ease infinite;
  color: #333;
  min-height: 100vh;
  margin: 0;
  transition: background-color 0.3s ease, color 0.3s ease;
  box-sizing: border-box;
  position: relative;
  overflow-x: hidden;
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

body.dark-mode {
  background: linear-gradient(135deg, #2c1810 0%, #1a1a2e 25%, #16213e 50%, #0f3460 75%, #2c1810 100%);
  background-size: 400% 400%;
  animation: gradientShift 8s ease infinite;
  color: #eee;
}

#darkModeContainer {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 100;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.9), rgba(240, 240, 240, 0.8));
    padding: 10px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15), inset 0 1px 2px rgba(255,255,255,0.3);
    display: flex;
    align-items: center;
    gap: 10px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.2);
}

body.dark-mode #darkModeContainer {
    background: linear-gradient(145deg, rgba(0, 0, 0, 0.8), rgba(20, 20, 20, 0.7));
    border: 1px solid rgba(255,255,255,0.1);
}

#darkModeContainer label {
    font-weight: bold;
    color: #333; /* Default light mode color */
}

body.dark-mode #darkModeContainer label {
    color: #eee; /* Dark mode color */
}

#creditContainer {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 100;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.9), rgba(240, 240, 240, 0.8));
    padding: 8px 12px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15), inset 0 1px 2px rgba(255,255,255,0.3);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.2);
    transition: all 0.3s ease;
}

#creditContainer:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.2);
}

body.dark-mode #creditContainer {
    background: linear-gradient(145deg, rgba(0, 0, 0, 0.8), rgba(20, 20, 20, 0.7));
    border: 1px solid rgba(255,255,255,0.1);
}

#creditContainer a {
    color: #9c27b0;
    text-decoration: none;
    font-weight: bold;
    font-size: 0.9em;
    font-family: 'Fredoka', sans-serif;
    transition: color 0.3s ease;
}

#creditContainer a:hover {
    color: #7b1fa2;
}

body.dark-mode #creditContainer a {
    color: #d1c4e9;
}

body.dark-mode #creditContainer a:hover {
    color: #b39ddb;
}

.floating-button {
    position: absolute;
    top: 65px; /* Adjust this value to position it right below the dark mode toggle */
    right: 20px; /* Align with dark mode toggle */
    z-index: 100;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(145deg, #9c27b0, #7b1fa2);
    color: white;
    border: none;
    font-size: 1.5em;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2), inset 0 1px 2px rgba(255,255,255,0.2);
    transition: all 0.3s ease;
}

.floating-button:hover {
    background: linear-gradient(145deg, #ab47bc, #8e24aa);
    transform: scale(1.1) rotate(10deg);
    box-shadow: 0 6px 16px rgba(0,0,0,0.3);
}

.floating-button:active {
    transform: scale(0.95);
}

body.dark-mode .floating-button {
    background-color: #9370db; /* Lavender */
    box-shadow: 0 2px 5px rgba(255, 255, 255, 0.1);
}

body.dark-mode .floating-button:hover {
    background-color: #7b68ee; /* MediumSlateBlue */
}

#logo {
  width: 200px;
  margin-bottom: 20px;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.2));
  transition: transform 0.3s ease, filter 0.3s ease;
}

#logo:hover {
  transform: scale(1.05) rotate(2deg);
  filter: drop-shadow(0 6px 12px rgba(0,0,0,0.3));
}

h1 {
  color: #ff69b4;
  text-align: center;
  margin-bottom: 20px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

body.dark-mode h1 {
    color: #9370db; /* Lavender */
    text-shadow: 2px 2px 4px rgba(255, 255, 255, 0.1);
}

textarea {
  width: 90%;
  max-width: 600px;
  height: 150px;
  margin-bottom: 15px;
  padding: 15px;
  border: 2px solid #ffb347;
  border-radius: 15px;
  font-size: 16px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1), inset 0 1px 3px rgba(255,255,255,0.3);
  resize: vertical;
  background: linear-gradient(145deg, #fff9c4, #ffe082);
  font-family: 'Fredoka', sans-serif; /* Changed font family */
  color: #333;
  transition: all 0.3s ease;
  box-sizing: border-box; /* Added for consistent sizing */
}

textarea:focus {
  border-color: #ff9800;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15), 0 0 0 3px rgba(255, 152, 0, 0.2);
  transform: translateY(-2px);
}

body.dark-mode textarea {
    background: linear-gradient(145deg, #2a2a2a, #1e1e1e);
    border-color: #8b4513; /* SaddleBrown */
    color: #eee;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3), inset 0 1px 3px rgba(255,255,255,0.1);
}

body.dark-mode textarea::placeholder {
    color: #bbb;
}

button {
  padding: 12px 24px;
  font-size: 18px;
  background: linear-gradient(145deg, #9c27b0, #7b1fa2);
  color: white;
  border: none;
  border-radius: 25px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2), inset 0 1px 2px rgba(255,255,255,0.2);
  margin-top: 15px;
  font-weight: bold;
  font-family: 'Fredoka', sans-serif; /* Changed font family */
  position: relative;
  overflow: hidden;
}

button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: left 0.5s;
}

button:hover {
  background: linear-gradient(145deg, #ab47bc, #8e24aa);
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

button:hover::before {
  left: 100%;
}

button:active {
  transform: translateY(0);
}

body.dark-mode button {
    background: linear-gradient(145deg, #9370db, #7b68ee);
    box-shadow: 0 4px 8px rgba(255, 255, 255, 0.1);
}

body.dark-mode button:hover {
    background: linear-gradient(145deg, #7b68ee, #5e35b1);
}

#options {
  width: 90%;
  max-width: 600px;
  margin-top: 15px;
  padding: 15px 20px;
  border: 1px solid #a5d6a7;
  border-radius: 15px;
  background: linear-gradient(145deg, #e8f5e9, #c8e6c9);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1), inset 0 1px 3px rgba(255,255,255,0.3);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all 0.3s ease;
  box-sizing: border-box; /* Added for consistent sizing */
}

body.dark-mode #options {
    background: linear-gradient(145deg, #223322, #1a2e1a);
    border-color: #384d38;
}

.options-section {
  border: 1px solid #b39ddb; /* Light purple border for sections */
  border-radius: 10px;
  padding: 10px 15px;
  margin-bottom: 15px;
  background: linear-gradient(145deg, #f3e5f5, #e1bee7);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05), inset 0 1px 2px rgba(255,255,255,0.3);
  transition: all 0.3s ease;
}

body.dark-mode .options-section {
  background: linear-gradient(145deg, #3a2b4d, #2e1f3a);
  border-color: #5e35b1; /* Medium purple */
}

.options-section h3 {
  color: #5e35b1; /* Medium purple */
  margin-top: 0;
  margin-bottom: 10px;
  border-bottom: 1px solid #d1c4e9; /* Very light grey-purple */
  padding-bottom: 5px;
  transition: color 0.3s ease, border-color 0.3s ease;
}

body.dark-mode .options-section h3 {
  color: #d1c4e9; /* Very light grey-purple */
  border-color: #5e35b1; /* Medium purple */
}

.option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 10px; /* Added spacing between toggle rows */
}

#options label {
  font-weight: bold;
  color: #2e7d32; /* Dark green */
  margin-right: 10px;
}

body.dark-mode #options label {
    color: #a5d6a7; /* Light green */
}

#violent-mode-warning,
#very-violent-mode-warning,
#ultraviolence-warning,
#marathon-script-warning,
#gorefest-warning,
#chaotic-blood-warning,
#profanity-warning,
#twisteds-warning,
#random-characters-warning,
#plot-twist-warning {
  font-size: 0.9em;
  color: #c62828; /* Dark red */
  margin-top: 5px;
  padding: 10px;
  background-color: #ffcdd2; /* Light red */
  border: 1px solid #ef9a9a; /* Lighter red */
  border-radius: 8px;
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

body.dark-mode #violent-mode-warning,
body.dark-mode #very-violent-mode-warning,
body.dark-mode #ultraviolence-warning,
body.dark-mode #marathon-script-warning,
body.dark-mode #gorefest-warning,
body.dark-mode #chaotic-blood-warning,
body.dark-mode #profanity-warning,
body.dark-mode #twisteds-warning,
body.dark-mode #random-characters-warning,
body.dark-mode #plot-twist-warning {
    background: linear-gradient(145deg, #5a1212, #3a1a1a);
    border-color: #7f1c1c;
    color: #ffcdd2; /* Light red */
}

#add-narrator-warning {
  font-size: 0.9em;
  color: #c62828;
  margin-top: 5px;
  padding: 10px;
  background-color: #ffcdd2;
  border: 1px solid #ef9a9a;
  border-radius: 8px;
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

body.dark-mode #add-narrator-warning {
  background: linear-gradient(145deg, #5a1212, #3a1a1a);
  border-color: #7f1c1c;
  color: #ffcdd2;
}

#characters,
#output,
#createToonSection,
#saveLoadSection {
  width: 90%;
  max-width: 600px;
  margin-top: 25px;
  padding: 20px;
  border: 1px solid #b39ddb; /* Light purple */
  border-radius: 15px;
  background: linear-gradient(145deg, #ede7f6, #d1c4e9);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1), inset 0 1px 3px rgba(255,255,255,0.3);
  transition: all 0.3s ease;
  box-sizing: border-box; /* Added for consistent sizing */
  position: relative;
  z-index: 2;
}

body.dark-mode #characters,
body.dark-mode #output,
body.dark-mode #createToonSection,
body.dark-mode #saveLoadSection {
    background: linear-gradient(145deg, #3a2b4d, #2e1f3a);
    border-color: #5e35b1; /* Medium purple */
}

#characters h2,
#createToonSection h2 {
  color: #5e35b1; /* Medium purple */
  margin-top: 0;
  margin-bottom: 15px;
  border-bottom: 1px solid #d1c4e9; /* Very light grey-purple */
  padding-bottom: 10px;
  transition: color 0.3s ease, border-color 0.3s ease;
}

body.dark-mode #characters h2,
body.dark-mode #createToonSection h2 {
    color: #d1c4e9; /* Very light grey-purple */
    border-color: #5e35b1; /* Medium purple */
}

.characters-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  border-bottom: 1px solid #d1bee7; /* Very light grey-purple */
  padding-bottom: 10px;
  transition: border-color 0.3s ease;
}

body.dark-mode .characters-header {
    border-color: #5e35b1; /* Medium purple */
}

.characters-header h2 {
  margin: 0;
  border-bottom: none;
  padding-bottom: 0;
}

/* Updated style for the toggle button */
.toggle-button {
  background-color: #ab47cc; /* A shade of purple */
  color: white;
  border: none;
  border-radius: 50%; /* Make it round */
  width: 30px; /* Fixed width */
  height: 30px; /* Fixed height */
  font-size: 1.2em; /* Adjust font size */
  font-weight: bold;
  cursor: pointer;
  padding: 0;
  margin-top: 0;
  display: flex; /* Use flexbox to center content */
  justify-content: center;
  align-items: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: background-color 0.3s ease, transform 0.1s ease, color 0.3s ease, box-shadow 0.3s ease;
}

.toggle-button:hover {
  background-color: #8e24aa; /* Darker purple on hover */
  transform: scale(1.05); /* Slightly enlarge on hover */
}

.toggle-button:active {
    transform: scale(0.95); /* Shrink slightly when clicked */
}

body.dark-mode .toggle-button {
    background-color: #d1c4e9; /* Very light grey-purple */
    color: #3a2b4d; /* Dark purple */
    box-shadow: 0 2px 4px rgba(255, 255, 255, 0.1);
}

body.dark-mode .toggle-button:hover {
    background-color: #b39ddb; /* Light purple */
    color: #3a2b4d; /* Dark purple */
}

.character-selection-buttons {
    display: flex;
    gap: 10px; /* Space between buttons */
    margin-bottom: 15px;
    justify-content: center; /* Center the buttons */
    flex-wrap: wrap; /* Allow buttons to wrap on smaller screens */
}

.character-selection-buttons button { /* Apply to both select and unselect */
  margin-top: 0; /* Adjust margin */
  padding: 8px 16px;
  font-size: 1em;
  background-color: #ab47bc; /* Light purple */
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  font-family: 'Fredoka', sans-serif; /* Changed font family */
}

.character-selection-buttons button:hover {
    background-color: #8e24aa; /* Darker purple */
}

body.dark-mode .character-selection-buttons button {
    background-color: #d1c4e9; /* Very light grey-purple */
    color: #3a2b4d; /* Dark purple */
}

body.dark-mode .character-selection-buttons button:hover {
    background-color: #b39ddb; /* Light purple */
    color: #3a2b4d; /* Dark purple */
}

#character-list-container.collapsed {
  display: none;
}

/* Add style to hide the character selection buttons when the container is collapsed */
#character-list-container.collapsed ~ .character-selection-buttons {
    display: none;
}

.character-section-header {
  color: #7b1fa2; /* Purple */
  margin-top: 20px;
  margin-bottom: 10px;
  border-bottom: 1px dashed #e1bee7; /* Lighter purple */
  padding-bottom: 5px;
  transition: color 0.3s ease, border-color 0.3s ease;
}

body.dark-mode .character-section-header {
    color: #e1bee7; /* Lighter purple */
    border-color: #7b1fa2; /* Purple */
}

/* Enhanced character row styling */
.character-row {
  display: flex;
  align-items: flex-start; /* Align items to the start for better wrapping */
  margin-bottom: 8px;
  flex-wrap: wrap;
  padding: 8px;
  border-radius: 8px;
  transition: all 0.3s ease;
  position: relative;
}

.character-row:hover {
  background: rgba(255,255,255,0.1);
  transform: translateX(5px);
}

body.dark-mode .character-row:hover {
  background: rgba(255,255,255,0.05);
}

.character-row input[type="checkbox"] {
  margin-right: 8px;
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid #7b1fa2; /* Purple */
  border-radius: 4px;
  background-color: #f3e5f5; /* Very light purple */
  cursor: pointer;
  position: relative;
  top: 2px;
  transition: background-color 0.3s ease, border-color 0.3s ease;
  flex-shrink: 0; /* Prevent checkbox from shrinking */
}

body.dark-mode .character-row input[type="checkbox"] {
    background-color: #4a3c5c; /* Darker purple */
    border-color: #7b1fa2; /* Purple */
}

.character-row input[type="checkbox"]:checked {
  background-color: #7b1fa2; /* Purple */
}

body.dark-mode .character-row input[type="checkbox"]:checked {
    background-color: #d1c4e9; /* Very light grey-purple */
}

.character-row input[type="checkbox"]:checked::after {
  content: '\2713';
  display: block;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white; /* Checkmark color */
  font-size: 14px;
}

body.dark-mode .character-row input[type="checkbox"]:checked::after {
    color: #3a2b4d; /* Dark purple */
}

.character-row label {
  margin-left: 0;
  flex-grow: 1;
  cursor: pointer;
  font-weight: bold;
  color: #4527a0; /* Darker purple */
  transition: color 0.3s ease;
}

body.dark-mode .character-row label {
    color: #b39ddb; /* Light purple */
}

.character-description {
  font-style: italic;
  color: #673ab7; /* Medium purple */
  margin-left: 30px;
  margin-top: 4px;
  font-size: 0.9em;
  width: calc(100% - 30px); /* Adjust width to account for margin-left */
  /* Ensure description uses the main font */
  font-family: 'Fredoka', sans-serif;
  transition: color 0.3s ease;
  box-sizing: border-box; /* Added for consistent sizing */
}

body.dark-mode .character-description {
    color: #9575cd; /* Lighter purple */
}

#placeholder {
  text-align: center;
  font-style: italic;
  color: #9575cd; /* Lighter purple */
  margin-top: 15px;
  transition: color 0.3s ease;
}

body.dark-mode #placeholder {
    color: #b39ddb; /* Light purple */
}

#output {
  white-space: pre-wrap;
  overflow-x: auto;
  /* Change font to a default font for the script output */
  font-family: sans-serif;
  background: linear-gradient(145deg, #fffde7, #fff9c4);
  color: #3e2723; /* Dark brown */
  border: 1px solid #fff59d; /* Lighter yellow */
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05), 0 4px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  box-sizing: border-box;
  min-height: 150px; /* Ensure output has a visible area even when empty */
}

body.dark-mode #output {
    background: linear-gradient(145deg, #2b201e, #1f1714);
    border-color: #4e342e; /* Medium brown */
    color: #fffde7; /* Very light yellow */
}

.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 20px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  -webkit-transition: .4s;
  transition: .4s;
  border-radius: 20px;
}

body.dark-mode .slider {
    background-color: #555; /* Darker grey */
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  -webkit-transition: .4s;
  transition: .4s;
  border-radius: 50%;
}

body.dark-mode .slider:before {
    background-color: #ccc; /* Lighter grey */
}

input:checked+.slider {
  background-color: #ff80ab; /* Pink */
}

body.dark-mode input:checked+.slider {
    background-color: #e91e63; /* Deeper pink */
}

input:focus+.slider {
  box-shadow: 0 0 1px #ff80ab; /* Pink */
}

body.dark-mode input:focus+.slider {
    box-shadow: 0 0 1px #e91e63; /* Deeper pink */
}

input:checked+.slider:before {
  -webkit-transform: translateX(20px);
  -ms-transform: translateX(20px);
  transform: translateX(20px);
}

#createToonSection {
  margin-top: 25px;
  padding: 20px;
  border: 1px solid #b39ddb;
  border-radius: 15px;
  background: linear-gradient(145deg, #ede7f6, #d1c4e9);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1), inset 0 1px 3px rgba(255,255,255,0.3);
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  box-sizing: border-box; /* Added for consistent sizing */
}

#createToonSection input[type="text"],
#createToonSection textarea {
  width: calc(100% - 30px); /* Account for padding */
  max-width: 560px; /* Keep consistent with other text areas */
  padding: 10px;
  margin-bottom: 10px;
  border: 1px solid #ffb347;
  border-radius: 8px;
  font-size: 16px;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
  background-color: #fff9c4;
  font-family: 'Fredoka', sans-serif;
  color: #333;
  box-sizing: border-box;
  max-width: calc(100% - 150px); /* Adjust max-width based on button size */
}

body.dark-mode #createToonSection input[type="text"],
body.dark-mode #createToonSection textarea {
  background-color: #2a2a2a;
  border-color: #8b4513;
  color: #eee;
}

#createToonButton {
  margin-top: 10px;
  padding: 10px 20px;
  font-size: 16px;
}

#createdToonsList {
  margin-top: 20px;
  width: 100%;
  text-align: left;
}

#createdToonsList h3 {
  color: #5e35b1;
  margin-bottom: 10px;
  border-bottom: 1px solid #d1c4e9;
  padding-bottom: 5px;
  text-align: center;
}

body.dark-mode #createdToonsList h3 {
  color: #d1c4e9;
  border-color: #5e35b1;
}

#userToons {
  list-style-type: none;
  padding: 0;
}

#userToons li {
  background: linear-gradient(145deg, #f3e5f5, #e1bee7);
  border: 1px solid #b39ddb;
  border-radius: 12px;
  padding: 15px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  color: #4527a0;
  position: relative; /* For the delete button positioning */
  box-sizing: border-box; /* Added for consistent sizing */
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

body.dark-mode #userToons li {
  background: linear-gradient(145deg, #4a3c5c, #3a2b4d);
  border-color: #7b1fa2;
  color: #b39ddb;
}

#userToons li .toon-name {
  font-weight: bold;
  font-size: 1.1em;
  margin-bottom: 5px;
}

#userToons li .toon-description,
#userToons li .toon-appearance {
  font-size: 0.9em;
  margin-left: 10px;
}

#userToons li .toon-appearance {
  font-style: italic;
  margin-top: 5px;
}

#userToons li .toon-handles {
  font-size: 0.9em;
  margin-left: 10px;
  margin-top: 5px;
  color: #673ab7; /* Medium purple */
}

body.dark-mode #userToons li .toon-handles {
  color: #9575cd; /* Lighter purple */
}

#userToons li .delete-button,
#userToons li .edit-button { /* Apply styles to both edit and delete */
  position: absolute;
  top: 5px;
  width: 24px;
  height: 24px;
  font-size: 0.8em;
  padding: 0;
  margin: 0;
  border-radius: 50%; /* Round buttons */
  display: flex;
  justify-content: center;
  align-items: center;
  transition: background-color 0.2s, transform 0.1s;
}

#userToons li .delete-button {
  right: 5px;
  background-color: #e74c3c; /* Red */
  color: white;
}

#userToons li .delete-button:hover {
  background-color: #c0392b;
}

body.dark-mode #userToons li .delete-button {
  background-color: #c62828;
}

body.dark-mode #userToons li .delete-button:hover {
  background-color: #b71c1c;
}

#userToons li .edit-button {
  right: 35px; /* Position next to delete button */
  background-color: #3498db; /* Blue for edit */
  color: white;
  font-size: 0.7em; /* Slightly smaller font for "Edit" text */
  width: 35px; /* Adjust width for text */
  border-radius: 12px; /* More rectangular but still rounded */
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

#userToons li .edit-button:hover {
  background-color: #2980b9;
}

body.dark-mode #userToons li .edit-button {
  background-color: #5dade2;
}

body.dark-mode #userToons li .edit-button:hover {
  background-color: #2e86c1;
}

/* Styles for the edit textareas */
#userToons li .edit-input {
  width: calc(100% - 20px); /* Adjust width to fit */
  padding: 5px;
  margin-top: 5px;
  border: 1px solid #a5d6a7;
  border-radius: 5px;
  font-size: 0.9em;
  font-family: 'Fredoka', sans-serif;
  box-sizing: border-box;
  background-color: #fff9c4; /* Light yellow background */
  color: #333;
}

body.dark-mode #userToons li .edit-input {
  background-color: #2a2a2a;
  border-color: #384d38;
  color: #eee;
}

/* Styles for Save/Load Section */
#saveLoadSection {
    width: 90%;
    max-width: 600px;
    margin-top: 25px;
    padding: 20px;
    border: 1px solid #b39ddb;
    border-radius: 15px;
    background: linear-gradient(145deg, #ede7f6, #d1c4e9);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1), inset 0 1px 3px rgba(255,255,255,0.3);
    display: flex;
    flex-direction: column;
    gap: 15px; /* More space for rows */
    align-items: center;
    box-sizing: border-box;
}

body.dark-mode #saveLoadSection {
    background: linear-gradient(145deg, #3a2b4d, #2e1f3a);
    border-color: #5e35b1;
}

#saveLoadSection h2 {
    color: #5e35b1;
    margin-top: 0;
    margin-bottom: 15px;
    border-bottom: 1px solid #d1c4e9;
    padding-bottom: 10px;
    text-align: center;
    width: 100%;
}

body.dark-mode #saveLoadSection h2 {
    color: #d1c4e9;
    border-color: #5e35b1;
}

#saveLoadSection .option-row {
    width: 100%;
    justify-content: center; /* Center items in the row */
    gap: 10px; /* Space between input and button */
    margin-bottom: 0; /* Override default margin for option-row */
}

#saveLoadSection input[type="text"] {
    flex-grow: 1; /* Allow input to take available space */
    padding: 10px;
    border: 1px solid #ffb347;
    border-radius: 8px;
    font-size: 16px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
    background-color: #fff9c4;
    font-family: 'Fredoka', sans-serif;
    color: #333;
    box-sizing: border-box;
    max-width: calc(100% - 150px); /* Adjust max-width based on button size */
}

body.dark-mode #saveLoadSection input[type="text"] {
    background-color: #2a2a2a;
    border-color: #8b4513;
    color: #eee;
}

#saveScriptButton {
    margin-top: 0; /* Override default margin for buttons */
    padding: 10px 15px;
    font-size: 16px;
}

#savedScriptsList {
    list-style-type: none;
    padding: 0;
    width: 100%;
    margin-top: 15px;
    max-height: 300px; /* Limit height for scrollability */
    overflow-y: auto; /* Enable scrolling */
    border-top: 1px solid #d1c4e9;
    padding-top: 10px;
}

body.dark-mode #savedScriptsList {
    border-color: #5e35b1;
}

/* Enhanced saved scripts styling */
#savedScriptsList li {
  background: linear-gradient(145deg, #f3e5f5, #e1bee7);
  border: 1px solid #b39ddb;
  border-radius: 12px;
  padding: 15px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  color: #4527a0;
  box-sizing: border-box;
  align-items: flex-start;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

#savedScriptsList li::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: left 0.5s;
}

#savedScriptsList li:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.15);
}

#savedScriptsList li:hover::before {
  left: 100%;
}

#savedScriptsList li .script-info {
    flex-grow: 1;
    margin-right: 10px;
    display: flex;
    flex-direction: column;
    width: 100%; /* Take full width */
    margin-bottom: 10px; /* Space between info and buttons */
}

#savedScriptsList li .script-title {
    font-weight: bold;
    font-size: 1.1em;
    margin-bottom: 5px;
}

#savedScriptsList li .script-date {
    font-size: 0.85em;
    color: #673ab7; /* Medium purple */
}

body.dark-mode #savedScriptsList li .script-date {
    color: #9575cd;
}

#savedScriptsList li .script-actions { /* New container for buttons */
    display: flex;
    flex-wrap: wrap; /* Allow buttons to wrap */
    gap: 8px; /* Space between buttons */
    width: 100%; /* Take full width */
    justify-content: flex-end; /* Align buttons to the right */
}

#savedScriptsList li button {
    margin-left: 0; /* Reset margin */
    padding: 5px 10px;
    font-size: 0.9em;
    border-radius: 15px;
    margin-top: 0; /* Ensure buttons don't have top margin */
    flex-shrink: 0; /* Prevent buttons from shrinking */
}

#savedScriptsList li .read-button { /* New read button style */
    background-color: #20b2aa; /* Lightseagreen */
}

#savedScriptsList li .read-button:hover {
    background-color: #1a8f87;
}

body.dark-mode #savedScriptsList li .read-button {
    background-color: #48d1cc; /* Turquoise */
}

body.dark-mode #savedScriptsList li .read-button:hover {
    background-color: #20b2aa;
}

#savedScriptsList li .load-button {
    background-color: #4CAF50; /* Green */
}

#savedScriptsList li .load-button:hover {
    background-color: #45a049;
}

body.dark-mode #savedScriptsList li .load-button {
    background-color: #66bb6a;
}

body.dark-mode #savedScriptsList li .load-button:hover {
    background-color: #4caf50;
}

#savedScriptsList li .remove-memory-button { /* Style for "Remove from Memory" */
    background-color: #e74c3c; /* Red */
}

#savedScriptsList li .remove-memory-button:hover {
    background-color: #c0392b;
}

body.dark-mode #savedScriptsList li .remove-memory-button {
    background-color: #c62828;
}

body.dark-mode #savedScriptsList li .remove-memory-button:hover {
    background-color: #b71c1c;
}

#savedScriptsList li .delete-button {
    background-color: #e74c3c; /* Red */
}

#savedScriptsList li .delete-button:hover {
    background-color: #c0392b;
}

body.dark-mode #savedScriptsList li .delete-button {
    background-color: #c62828;
}

body.dark-mode #savedScriptsList li .delete-button:hover {
    background-color: #b71c1c;
}

#readScriptOutput {
    width: 90%;
    max-width: 600px;
    margin-top: 25px;
    padding: 20px;
    border: 1px solid #b39ddb;
    border-radius: 15px;
    background: linear-gradient(145deg, #ede7f6, #d1c4e9);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1), inset 0 1px 3px rgba(255,255,255,0.3);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
}

body.dark-mode #readScriptOutput {
    background: linear-gradient(145deg, #3a2b4d, #2e1f3a);
    border-color: #5e35b1;
}

#readScriptOutput h3 {
    color: #5e35b1;
    margin-top: 0;
    margin-bottom: 15px;
    border-bottom: 1px solid #d1c4e9;
    padding-bottom: 10px;
    text-align: center;
    width: 100%;
}

body.dark-mode #readScriptOutput h3 {
    color: #d1c4e9;
    border-color: #5e35b1;
}

#readScriptContent {
    white-space: pre-wrap;
    overflow-x: auto;
    font-family: sans-serif;
    background: linear-gradient(145deg, #fffde7, #fff9c4);
    color: #3e2723;
    border: 1px solid #fff59d;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05), 0 4px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    box-sizing: border-box;
    min-height: 200px;
    width: 100%;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
}

body.dark-mode #readScriptContent {
    background: linear-gradient(145deg, #2b201e, #1f1714);
    border-color: #4e342e;
    color: #fffde7;
}

#closeReadScriptButton {
    margin-top: 0;
    padding: 10px 20px;
    font-size: 16px;
}

/* Memory status display */
.memory-status {
    background-color: #e8f5e9; /* Light green */
    border: 1px solid #a5d6a7;
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 15px;
    color: #2e7d32; /* Dark green */
    font-size: 0.9em;
    text-align: center;
}

body.dark-mode .memory-status {
    background: linear-gradient(145deg, #223322, #1a2e1a);
    border-color: #384d38;
    color: #a5d6a7; /* Light green */
}

.memory-status strong {
    display: block;
    margin-bottom: 5px;
    font-size: 1em;
}

/* Custom Rules Styles */
.no-rules-message {
  text-align: center;
  font-style: italic;
  color: #9575cd;
  margin: 10px 0;
  padding: 10px;
}

body.dark-mode .no-rules-message {
  color: #b39ddb;
}

.custom-rule-item {
  background: linear-gradient(145deg, #f9f9f9, #f0f0f0);
  border: 1px solid #d1c4e9;
  border-radius: 10px;
  padding: 15px;
  margin-bottom: 10px;
  transition: all 0.3s ease;
}

body.dark-mode .custom-rule-item {
  background: linear-gradient(145deg, #4a4a4a, #3a3a3a);
  border-color: #7b1fa2;
}

.custom-rule-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.rule-content {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
}

.rule-label {
  font-weight: bold;
  color: #5e35b1;
  margin-left: 10px;
  flex-grow: 1;
  cursor: pointer;
}

body.dark-mode .rule-label {
  color: #d1c4e9;
}

.rule-description {
  color: #673ab7;
  font-size: 0.9em;
  margin-bottom: 10px;
  padding: 5px 10px;
  background: rgba(103, 58, 183, 0.05);
  border-radius: 5px;
  border-left: 3px solid #673ab7;
}

body.dark-mode .rule-description {
  color: #9575cd;
  background: rgba(149, 117, 205, 0.1);
  border-color: #9575cd;
}

.rule-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.edit-rule-button,
.delete-rule-button {
  padding: 5px 12px;
  font-size: 0.9em;
  border-radius: 15px;
  margin-top: 0;
  font-weight: normal;
}

.edit-rule-button {
  background-color: #3498db;
  color: white;
}

.edit-rule-button:hover {
  background-color: #2980b9;
}

.delete-rule-button {
  background-color: #e74c3c;
  color: white;
}

.delete-rule-button:hover {
  background-color: #c0392b;
}

body.dark-mode .edit-rule-button {
  background-color: #5dade2;
}

body.dark-mode .edit-rule-button:hover {
  background-color: #2e86c1;
}

body.dark-mode .delete-rule-button {
  background-color: #c62828;
}

body.dark-mode .delete-rule-button:hover {
  background-color: #b71c1c;
}

#addRuleButton {
  background-color: #4CAF50;
  color: white;
  padding: 10px 20px;
  font-size: 16px;
  margin-top: 0;
}

#addRuleButton:hover {
  background-color: #45a049;
}

body.dark-mode #addRuleButton {
  background-color: #66bb6a;
}

body.dark-mode #addRuleButton:hover {
  background-color: #4caf50;
}

.gambling-button {
  background: linear-gradient(45deg, #ff6b6b, #ffd93d, #6bcf7f, #4d96ff, #9b59b6);
  background-size: 300% 300%;
  animation: rainbowShift 2s ease infinite;
  color: white;
  font-size: 24px;
  font-weight: bold;
  padding: 15px 30px;
  border: none;
  border-radius: 15px;
  cursor: pointer;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
  margin: 20px 0;
  transition: all 0.3s ease;
}

.gambling-button:hover {
  transform: scale(1.1) rotate(5deg);
  box-shadow: 0 8px 25px rgba(0,0,0,0.4);
}

.gambling-button:active {
  transform: scale(0.95);
}

@keyframes rainbowShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.gambling-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.8);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(10px);
}

.gambling-result {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.9), rgba(240, 240, 240, 0.8));
  padding: 40px;
  border-radius: 20px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  max-width: 400px;
  margin: 20px;
}

body.dark-mode .gambling-result {
  background: linear-gradient(145deg, rgba(40, 40, 40, 0.9), rgba(20, 20, 20, 0.8));
  color: #eee;
}

#gamblingResultText {
  font-size: 24px;
  font-weight: bold;
  margin-bottom: 20px;
  color: #333;
}

body.dark-mode #gamblingResultText {
  color: #eee;
}

.gambling-result button {
  margin-top: 0;
}

/* Hide locked options initially */
.option-locked {
  display: none !important;
}

/* Special styling for joke toons */
.joke-character-row {
  background: linear-gradient(145deg, #fff3e0, #ffe0b2) !important;
  border: 2px dashed #ff9800 !important;
}

body.dark-mode .joke-character-row {
  background: linear-gradient(145deg, #3e2723, #2e1f14) !important;
  border-color: #ff9800 !important;
}

.joke-label {
  font-size: 0.8em;
  color: #ff9800 !important;
  font-weight: bold;
  font-style: italic;
}

body.dark-mode .joke-label {
  color: #ffb74d !important;
}